package com.zh.note.huawei.onehundred.玩牌高手;

import java.util.Scanner;

public class Main {
    public static void solveMethod(String[] values, int[] nums) {
        int[] dp = new int[nums.length];
        dp[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (i == 1) {
                dp[i] = Math.max(dp[i - 1], nums[i]);
            } else if (i == 2) {
                dp[i] = Math.max(dp[i - 1], nums[i] + nums[i - 2]);
            } else {
                dp[i] = Math.max(dp[i - 1], dp[i - 3] + nums[i] + nums[i - 2]);
            }
        }
        System.out.println(dp[nums.length - 1]);
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        // String s1 = s.nextLine();
        String s1 = "1,-5,-6,4,3,6,-2";
        String[] values = s1.split(",");
        int[] nums = new int[values.length];
        for (int i = 0; i < values.length; i++) {
            nums[i] = Integer.parseInt(values[i]);
        }
        solveMethod(values, nums);
    }
}

